package Server.Poker.DGT;

public class ServerUserItem {
	boolean m_bAcitve; // �����־
	boolean m_bAndroid; // �����û�
	int m_lRevenue; // ��Ϸ˰��
	int m_wServerType; // ��Ϸ����
	tagUserRule m_UserRule = new tagUserRule(); // �û�����
	tagUserScore m_ScoreBorn = new tagUserScore(); // ԭ������
	tagUserScore m_ScoreModify = new tagUserScore(); // �������
	tagUserData m_UserData = new tagUserData(); // �û���Ϣ

	int m_wUserIndex; // �û�����
	int m_dwClientIP; // ���ӵ�ַ
	int m_dwLogonTime; // ��¼ʱ��
	int m_dwPlayTimeCount; // ��Ϸʱ��
	// ���캯��

	public ServerUserItem() {
		InitServerUserItem();
		Init();
	}

	// �û�ʤ��
	int GetUserWinRate() {
		// Ч�����
		// ASSERT(m_bAcitve==true);

		// ����ʤ��
		// tagUserScore * pUserScore=&m_ServerUserData.UserScoreInfo;
		int lPlayCount = m_UserData.lWinCount + m_UserData.lLostCount + m_UserData.lDrawCount + m_UserData.lFleeCount;
		if (lPlayCount != 0L)
			return (int) (m_UserData.lWinCount * 10000L / lPlayCount);

		return 0;
	}

	// �û�����
	int GetUserLostRate() {

		// ��������
		// tagUserScore * pUserScore=&m_ServerUserData.UserScoreInfo;
		int lPlayCount = m_UserData.lWinCount + m_UserData.lLostCount + m_UserData.lDrawCount + m_UserData.lFleeCount;
		if (lPlayCount != 0L)
			return (int) (m_UserData.lLostCount * 10000L / lPlayCount);

		return 0;
	}

	// �û�����
	int GetUserDrawRate() {
		// Ч�����
		// ASSERT(m_bAcitve==true);

		// �������
		// tagUserScore * pUserScore=&m_ServerUserData.UserScoreInfo;
		int lPlayCount = m_UserData.lWinCount + m_UserData.lLostCount + m_UserData.lDrawCount + m_UserData.lFleeCount;
		if (lPlayCount != 0L)
			return (int) (m_UserData.lDrawCount * 10000L / lPlayCount);

		return 0;
	}

	// �û�����
	int GetUserFleeRate() {
		// ��������
		// tagUserScore * pUserScore=&m_ServerUserData.UserScoreInfo;
		int lPlayCount = m_UserData.lWinCount + m_UserData.lLostCount + m_UserData.lDrawCount + m_UserData.lFleeCount;
		if (lPlayCount != 0L)
			return (int) (m_UserData.lFleeCount * 10000L / lPlayCount);

		return 0;
	}

	// ���ù���
	boolean SetUserRule(tagUserRule UserRule) {

		// ���ù���
		m_UserRule = UserRule;

		return true;
	}

	// ��Ϸ����
	boolean SetServerType(int wServerType) {
		m_wServerType = wServerType;

		return true;
	}

	// �޸Ļ���
	boolean WriteScore(tagScoreInfo ScoreInfo, int dwPlayTimeCount) {
		m_UserData.lScore += ScoreInfo.lScore;
		m_UserData.lGameGold += ScoreInfo.lGameGold;
		return true;
	}

	// ����״̬
	boolean SetUserStatus(int cbUserStatus, int wTableID, int wChairID) {

		// ���ñ���
		m_UserData.wTableID = wTableID;
		m_UserData.wChairID = wChairID;
		m_UserData.cbUserStatus = cbUserStatus;

		return true;
	}

	// �޸��ʿ�
	boolean ModifyBankStorageGold(int lStorageCount) {
		m_UserData.lStorageGold += lStorageCount;
		m_ScoreModify.lStorageGold += lStorageCount;

		return true;
	}

	// ��ʼ��
	void InitServerUserItem() {
		m_bAcitve = false;
		m_bAndroid = false;
		m_lRevenue = 0;
		m_wServerType = 0;
		m_dwClientIP = 0;
		m_wUserIndex = 0xFFFF;
		m_dwPlayTimeCount = 0;
		m_dwLogonTime = Constants.time();

		// by ele
		m_bAcitve = true;

		return;
	}

	// ������Ϣ
	boolean GetUserScoreInfo(tagUserScore ScoreModifyInfo) {
		// ���ñ���
		ScoreModifyInfo = m_ScoreModify;
		return true;
	}

	public int getUid() {
		return dwUserID;
	}

	public tagUserData GetUserData() {
		return m_UserData;
	}

	public void SetAndroidUser(boolean bAndroidUser) {
		m_bAndroid = bAndroidUser;
	}

	public boolean IsAndroidUser() {
		return m_bAndroid;
	}

	public boolean IsActive() {
		return m_bAcitve;
	}

	public void setUid(Integer lUid) {
		dwUserID = lUid;
	}

	public int GetUserID() {
		return m_UserData.dwUserID;
	}

	public int wChairID; // ����λ��
	public int cbUserStatus; // �û�״̬
	public int isAndroidUser;
	// ������Ϣ
	public int dwFaceID; // ͷ������
	public int cbVipLevel; // ��Ա�ȼ�
	public int cbGender; // �û��Ա�
	public int cbOnline; // �Ƿ�����
	public int dwUserID; // �û� I D
	public int dwGroupID; // ��������
	public int lUserScore; // �û�����
	public String szNickName = ""; // �û��ǳ�
	public String szIP;

	void SetUserStatus(int bUserStatus) {
		cbUserStatus = bUserStatus;
	};

	public void Init() {
		dwUserID = 0;
		dwGroupID = 0;
		lUserScore = 0;
		dwFaceID = 0;
		cbVipLevel = 0;
		cbGender = 0;
		cbOnline = 0;

		wChairID = 0;
		cbUserStatus = 0;
		isAndroidUser = 0;
		szNickName = "";
		szIP = "";
	}

	int GetUserScore() {
		return lUserScore;
	}

	public String GetUserInfo() {
		return String.format("%d#%s", dwUserID, szNickName);
	}

}
